using System;
using System.Data.SqlClient;

using SBPweb.Data;

#if SQL2005
namespace SBPweb.Data.SQL2005
{

	/// <summary>
	/// A selection factory that implements a read all command
	/// </summary>
	public class ReadAllCommandFactory : ISelectionFactory<NullableIdentity>
	{

		#region Private fields

		private string mCommandName;

		#endregion

		#region Constructor logic

		/// <summary>
		/// Initializes a new ReadAllCommandFactory instance
		/// </summary>
		/// <param name="storedProcCommandName">Name of the read all stored procedure</param>
		public ReadAllCommandFactory(string storedProcCommandName)
		{
			mCommandName = storedProcCommandName;
		}

		#endregion

		#region ISelectionFactory<NullableIdentity> Members

		/// <summary>
		/// Constructs the read all SqlCommand
		/// </summary>
		/// <param name="db">SqlDatabase db</param>
		/// <param name="nullableIdentity">Nullable identity</param>
		/// <returns>SqlCommand instance</returns>
		public SqlCommand ConstructSelectCommand(SqlDatabase db, NullableIdentity nullableIdentity)
		{
			SqlCommand command = db.GetStoredProcCommand(mCommandName);
			return command;
		}

		#endregion

		#region IDbToBusinessEntityNameMapper Members

		/// <summary>
		/// Mapd db parameter to entity property
		/// </summary>
		/// <param name="dbParameter">name of the db parameter</param>
		/// <returns>entity property name</returns>
		public string MapDbParameterToBusinessEntityProperty(string dbParameter)
		{
			return dbParameter;
		}

		#endregion
	}
}
#endif